#coding=utf-8
'''
Created on 2013年9月2日

@author: xuben

时间辅助类
'''

import random
import time

'''
获取随机时间
base 基数
offset 误差
'''
def getRandomTime(base, offset):
    upper = base + offset
    lower = base - offset
    if lower < 0:
        lower = 0
    return random.uniform(lower, upper)

'''
获取随机次数
'''
def getRandomCount(base, offset):
    upper = base + offset
    lower = base - offset
    if lower < 0:
        lower = 0
    return random.randint(lower, upper)

'''
获取当前时间
'''
def getCurrentLocalTime():
    currentLocalTime = time.localtime(time.time())
    return time.strftime("%Y-%m-%d %H:%M:%S", currentLocalTime)

'''
获取当前小时
'''
def getCurrentLocalHour():
    return time.localtime(time.time())[3]

if __name__ == '__main__':
    getCurrentLocalHour()